package com.demo.java.OD151_200.OD170;

/**
 * @author bug菌
 * @Source 公众号：猿圈奇妙屋
 * @date: 2025-02-21 17:35
 */
public class ServiceTest {
    public static void main(String[] args) {
        try {
            // 模拟请求
            String response = sendRequest("http://localhost:8080/hello?name=John");
            System.out.println("Response: " + response);

            // 检查日志和追踪信息
            System.out.println("Checking Jaeger for distributed tracing...");
            // 假设我们有一个Jaeger客户端
            checkJaegerTraces();

            // 模拟故障注入
            simulateFault("payment-service");
            System.out.println("Simulated failure, checking system stability...");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static String sendRequest(String url) {
        // 使用HttpClient发送请求
        return "Hello, John";
    }

    private static void checkJaegerTraces() {
        // 假设我们有Jaeger追踪查询逻辑
        System.out.println("Jaeger traces are available for analysis.");
    }

    private static void simulateFault(String serviceName) {
        // 模拟服务故障
        System.out.println(serviceName + " is now failing...");
    }
}